package com.example.demo.service.Impl;


import com.example.demo.dao.IQj;
import com.example.demo.model.Qj;
import com.example.demo.service.IQjService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator 董婷
 */

@Service
public class QjServiceImpl implements IQjService{

    @Autowired
    private IQj qjMapper;
    @Override
    public int insertQj(Qj qj){
        int qjValue=0;

       Qj qj1=new Qj();
        qj1.setQjid(qj.getQjid());
        List<Qj> getQ=qjMapper.getAllQj(qj1);
        if(getQ.size()>0){
            qjValue=-1;

        }else{
            qjValue=qjMapper.insertQj(qj);
        }

        return qjValue;
    }

    @Override
    public List<Qj> getAllQj(Qj qj) {


        return qjMapper.getAllQj(qj);
    }

    @Override
    public int updateQj(Qj qj) {
        int qjValues=0;
        if(qj.getQjid()!=0){



            qjValues=qjMapper.updateQj(qj);
        }
        return qjValues;
    }

    @Override
    public int deleteQj(Qj qj) {
        int qjValues=0;
        if(qj.getQjid()!=0)
        {
            //主键是否与其他表有关联

           qjValues=qjMapper.deleteQj(qj);
        }
        return qjValues;
    }

    @Override
    public Qj getQj(Qj qj) {
        Qj qj1=new Qj();
        if(qj.getQjid()!=0){
            qj1=qjMapper.getQj(qj);
        }
        return qj1;
    }

}
